
/**
 * AJAX 载入用户日志列表页面
 *
 * @return 	void
 */
function bindUserListArticles() {
	$(".ajax-list-articles").click(function(){
		$(".slider-item a").removeClass('selected-slider-item');
		$(this).addClass('selected-slider-item').blur();
		loadListArticles($(this).attr('href'));
		return false;
	});
}

/**
 * AJAX 响应分页链接请求
 *
 * @return void
 */
function bindPagesArticles() {
	$(".edit-photo-link").click(function(){
		addMmLightBox('edit-photo-box', 'Edit Photo: ' + $(this).attr('title'), 1);
		var photoID = $(this).attr('target');
		$("#edit-photo-title").val($(this).attr('title'));
		$("#edit-photo-desc").val($("#photo-thumb-" + photoID).attr('alt'));
		var categoryID = $(this).attr('name');
		$("#photo-category-list option").each(function(i){
			if(categoryID == $(this).val()) {
				this.selected = true;
			} else {
				this.selected = false;
			}
		});

		$("#edit-photo-form").submit(function(){
			var newCategoryID = $("#photo-category-list").val();
			//do some thing
			if($("#photo-thumbs-category").attr("name") == categoryID && categoryID != newCategoryID) {
				$("#photo-box-" + photoID).hide();
			}
			return false;
		});


		return false;
	});

	$(".delete-photo-link").click(function(){
		if(confirm('Do you want to delete the photo: ' + $(this).attr('title'))) {
			$("#photo-box-" + $(this).attr('target')).hide();
		} else {
			$(this).blur();
		}
		return false;
	});

	$(".pages-link").click(function(){
		loadListArticles($(this).attr('href'));
		return false;
	});

	$(".pages-list").removeAttr("onchange");
	$(".pages-list").change(function(){
		loadListArticles($(this).val());
		return false;
	});
}

/**
 * 载入日志列表
 *
 * @param string load_url 载入地址
 * @return void
 */
function loadListArticles(load_url) {
	addMmLightBoxMsg('Wait a moment please, loading data ...', 0, 0, 1);
	$.get(load_url, function(dt){
		$('#user-body-box').height('auto').html(dt);
		reactHeight();
		removeMmLightBoxMsg();
		bindPagesArticles();
	});
}
